package pdai.a2_多线程;

public class TestThread3 implements Runnable {
    private int  ticketNums=10;

    @Override
    public void run() {

        while (true){
            if (ticketNums<=0){
                break;
            }
            System.out.println(Thread.currentThread().getName()+"拿到了第"+ticketNums--+"张票");
        }
    }

    public static void main(String[] args) {
        TestThread3 ts=new TestThread3();
        new  Thread(ts,"小明").start();
        new  Thread(ts,"老师").start();
        new  Thread(ts,"中介").start();
    }
}
